﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;

namespace otis.common
{
    public class Assistanter
    {
        public static string GetGuid()
        {
            return System.Guid.NewGuid().ToString("N");
        }

        /// <summary>
        /// 页面导航
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="sender"></param>
        public static void PageNavigate(Frame frame, object sender)
        {
            string barName = string.Empty;
            AppBarButton bar = sender as AppBarButton;
            Button btn = sender as Button;
            if (bar == null && btn == null)
            {
                return;
            }
            else { 
                if(bar != null)
                    barName = bar.Name.Trim();
                else if(bar != null)
                    barName = bar.Name.Trim();
            }
             
            switch (barName)
            {
                case "home":
                    frame.Navigate(typeof(MainPage)); break;
                case "back":
                    frame.GoBack();break;
                case "company":
                    frame.Navigate(typeof(views.company.CompanyList));break;
                case "product":
                    frame.Navigate(typeof(views.product.ProductList));break;
                case "project":
                    frame.Navigate(typeof(views.project.ProjectList));break;
                case "setup":
                    frame.Navigate(typeof(PageSetup));break;
                case "service":
                    frame.Navigate(typeof(PageService));break;
                default:
                    break;
            }
        }
    }
}
